const sql = require('mssql')

const config = {
    user: 'sa',
    password: 'GJPF4.7PTW4',
    server: 'localhost', // You can use 'localhost\\instance' to connect to named instance
    database: 'partlib',
}

(async function () {
    try {
        let pool = await sql.connect(config)
        let result1 = await pool.request()
            .query('SELECT * FROM d_Part')
            //.input('input_parameter', sql.Int, value)
            //.query('select * from mytable where id = @input_parameter')

            
        console.dir(result1)
    
        // Stored procedure
        
        // let result2 = await pool.request()
        //     .input('input_parameter', sql.Int, value)
        //     .output('output_parameter', sql.VarChar(50))
        //     .execute('procedure_name')
        
        // console.dir(result2)
    } catch (err) {
        console.log(err);
    }
})()

sql.on('error', err => {
    // ... error handler
})
